import getsqlline from "../mysql/mysqllines";
import { dosql } from "../tool/sqlTool";
import { Users } from "../tool/varType";
// 读取登录数据
export async function readLoiginData(user: Users) {
  return dosql(`select * from users where email=? and password=? `, [
    user.email,
    user.password,
  ]);
}
// 注册用户数据
export async function readRegisterData(user: Users) {
  return dosql(
    `insert into users (email,password,nick,introduction,uid) values (?,?,?,?,uuid()) `,
    [user.email, user.password, user.nick, user.introduction]
  );
}
// 获取用户数据
export async function getUserList(page: number) {
  return dosql(
    `select * from users order by id desc limit ${(page - 1) * 10},10;`,
    []
  );
}
//删除用户
export async function delUser(id: string) {
  return dosql(`delete from users where id=${id}`, []);
}
// 更新用户
export async function updateUser(user: Users) {
  return dosql(
    `update users set email=?,password=?,nick=?,introduction=? where id=?`,
    [user.email, user.password, user.nick, user.introduction, user.id]
  );
}
